import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MallOrderVO, MallOrderForm, MallOrderQuery } from '@/api/mall/mallOrder/types';

/**
 * 查询订单主信息列表
 * @param query
 * @returns {*}
 */

export const listMallOrder = (query?: MallOrderQuery): AxiosPromise<MallOrderVO[]> => {
  return request({
    url: '/mall/mallOrder/wechat/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单主信息详细
 * @param id
 */
export const getMallOrder = (id: string | number): AxiosPromise<MallOrderVO> => {
  return request({
    url: '/mall/mallOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增订单主信息
 * @param data
 */
export const addMallOrder = (data: MallOrderForm) => {
  return request({
    url: '/mall/mallOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单主信息
 * @param data
 */
export const updateMallOrder = (data: MallOrderForm) => {
  return request({
    url: '/mall/mallOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单主信息
 * @param id
 */
export const delMallOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/mall/mallOrder/' + id,
    method: 'delete'
  });
};
export const orderRefund = (data: MallOrderForm) => {
  return request({
    url: '/mall/mallOrder/wechat/refund',
    method: 'post',
    data: data
  });
};
